-- NewRenownPanel

local ListFullSpreadMenu = require("app.widget.ListFullSpreadMenu")
local FirstRenownRender = import(".renders.FirstRenownRender")
local SecondRenownRender = import(".renders.SecondRenownRender")

local ClassRef = app.mvc.createPanelClass(...)

function ClassRef.create(node)
	local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.NewRenownPanelNode))
	if node == nil then
		ccui.Helper:doLayout(sprite)
	end
	sprite:init()
	return sprite
end

function ClassRef:init(data)
	self.super.init(self, data)

	local function operate( data, btnClass, op, isFirstBtnHadOpened ) -- isFirstBtnHadOpened-一级菜单是否展开过
		if "btn" == btnClass then -- 一级按钮处理
			if op == "open" then -- 展开
			elseif op == "close" then -- 合上
				if 1 == isFirstBtnHadOpened then -- 1级菜单之前就展开过
					executeFunc(self._onPanelHandler, "RenownPanel_removeNewFlag", data)
				end
			else
				-- print( " ------------------->>>>>> NewRenownPanel 一级菜单返回未知操作 " )
			end
		elseif "subBtn" == btnClass then -- 二级按钮处理
			executeFunc(self._onPanelHandler, "RenownPanel_buyRenown", data)
		end
	end

	local params = {
		list = self._ui["Panel/ListView"],
		btnClass = FirstRenownRender,
		subBtnClass = SecondRenownRender,
		operate = operate,
		mutexMenu = true
	}
	self._renownList = ListFullSpreadMenu.new(params)
end

function ClassRef:getScrollView()
	return self._renownList
end

function ClassRef:remove()
	self._renownList:remove()
end

function ClassRef:registerOnOperate( cb )
	self._onPanelHandler = cb
end

return ClassRef
